import { defineStore } from 'pinia'
import { ref } from 'vue'
import { userGetInfoService } from '@/api/user'

export const useUserStore = defineStore(
  'user-info',
  () => {
    const token = ref('')
    const setToken = (t) => (token.value = t)
    const user = ref({})
    const setUser = async (data) => {
      user.value = data
    }
    const setImage = (image) => {
      user.value.avatar = image
    }
    const removeToken = () => {
      localStorage.removeItem('user-info')

      // 本地存储中删除big-user
    }
    return {
      setImage,
      removeToken,
      token,
      setToken,
      setUser,
      user
    }
  },
  { persist: true }
)
